/*
 * Copyright (c) 2020, 2023, 3044483124@qq.com All rights reserved.
 *
 */
package cn.itcast;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;

/**
 * <p>Project: JavaStudy - Img1
 * <p>Powered by jiangbo On 2023-01-05
 * 20:40:42
 * <p>Created by IntelliJ IDEA
 *
 * @author jiangbo [3044483124@qq.com]
 * @version 1.0
 * @since 8/17
 */
public class Img1 {
    public static void main(String[] args) throws Exception{
        int w = 800;
        int h = 600;
        BufferedImage i = new BufferedImage(w, h, 1);
        Graphics g = i.getGraphics();
        g.setColor(Color.RED);
        g.fillRect(0, 0, w, h);
        g.setColor(Color.WHITE);
        int xx = 400, yy = 300;//坐标中心
        int angle = 0;//角度
        int cw = 200, ch = 200;//控制圆形的水平直径 垂直直径
        for (int n = 0; n <= 36; n++) {
            int x = xx - (int) (Math.sin(angle * Math.PI / 360) * cw);
            int y = yy - (int) (Math.cos(angle * Math.PI / 360) * ch);
            g.fillOval(x, y, 10, 10);
            angle += 20;
        }
        ImageIO.write(i, "png", new File("img1.png"));
        //直接打开图像
        Runtime.getRuntime().exec("cmd /k start img1.png");

    }
}


